local fangquan = fk.CreateSkill{
  name = "iberia__fangquan",
}

Fk:loadTranslationTable{
  [fangquan.name] = "放权",
  [":"..fangquan.name] = "准备阶段，你可以将一张红色牌当【乐不思蜀】置于你的判定区，令一名其他角色于本回合结束后进行一个额外回合。",

  ["#"..fangquan.name] = "放权：将一张红色牌当【乐不思蜀】置于你的判定区",
  ["#"..fangquan.name.."-ex"] = "放权：令一名其他角色于本回合结束后进行一个额外回合",
}

fangquan:addEffect(fk.EventPhaseStart, {
  anim_type = "support",
  can_trigger = function (self, event, target, player, data)
    return player:hasSkill(fangquan.name) and player == target and data.phase == Player.Start
    and table.find(player:getCardIds("he"), function (c) return Fk:getCardById(c).color == Card.Red end)
    and table.every(player:getCardIds("j"), function (c) return Fk:getCardById(c).trueName ~= "indulgence" end)
  end,
  on_cost = function (self, event, target, player, data)
    local cards = player.room:askToCards(player, {
      skill_name = fangquan.name,
      pattern = tostring(Exppattern { suit = {"diamond", "heart"} }),
      max_num = 1,
      min_num = 1,
      prompt = "#"..fangquan.name,
    })

    if #cards == 1 then
      event:setCostData(self, {card = cards[1]})
      return true
    end
  end,
  on_use = function (self, event, target, player, data)
    local room = player.room
    local card = Fk:cloneCard("indulgence")
    card.skillName = fangquan.name
    card:addSubcards(event:getCostData(self).cards)
    room:moveCardTo(card, Card.PlayerJudge, player, fk.ReasonPut, fangquan.name, nil, true, player)
    if player.dead then return end

    local tos = room:askToChoosePlayers(player, {
      targets = room:getOtherPlayers(player, false),
      min_num = 1,
      max_num = 1,
      prompt = "#"..fangquan.name.."-ex",
      skill_name = fangquan.name,
      cancelable = false,
    })

    tos[1]:gainAnExtraTurn(true, fangquan.name)
  end
})

return fangquan